In [1]:
#!python
# @NotebookService nb
Out[1]:
Using nb.display()
, the kernel will choose automatically the better output format possible according to the type of data.
In [2]:
nb.display(range(10))
Out[2]:
In [3]:
nb.display(dict(name="Adam", color="blue"))
Out[3]:
In [7]:
table = [{"x": 0, "y": 0},
{"x": 1, "y": 10},
{"x": 2, "y": 20},
{"x": 3, "y": 30},
{"x": 4, "y": 40},
{"x": 5, "y": 50},
{"x": 6, "y": 60}]
Out[7]:
In [8]:
nb.table(table)
Out[8]:
Helper methods allow you to force the type of output you want.
In [9]:
nb.markdown("**This is bold** and *this is italic*")
Out[9]:
In [10]:
nb.latex("$$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$")
Out[10]:
In [12]:
html_code = """
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
<tr>
<td>Ernst Handel</td>
<td>Roland Mendel</td>
<td>Austria</td>
</tr>
</table>
</body>
</html>"""
Out[12]:
In [13]:
nb.html(html_code)
Out[13]: